# Contributor: solidnerd <niclas@mietz.io>
# Maintainer: solidnerd <niclas@mietz.io>
pkgname=glab
pkgver=1.22.0
pkgrel=3
pkgdesc="Open source GitLab CLI tool written in Go"
url="https://github.com/profclems/glab"
arch="all"
license="MIT"
depends="git"
makedepends="go"
options="!check chmod-clean" # Need to be run in a git repo
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/profclems/glab/archive/v$pkgver.tar.gz"

export CGO_ENABLED=0

build() {
	make build GLAB_VERSION=$pkgver

	# XXX: When glab is run in fakeroot it segfaults for some reason
	# on ppc64le. By generating the compilation files here we
	# workaround that but we need to investigate why it segfaults in
	# fakeroot eventually.
	bin/glab completion --shell bash > bash.comp
	bin/glab completion --shell zsh > zsh.comp
	bin/glab completion --shell fish > fish.comp
}

package() {
	install -Dm755 "$builddir"/bin/glab -t "$pkgdir"/usr/bin/

	install -Dm644 bash.comp "$pkgdir"/usr/share/bash-completion/completions/glab.bash
	install -Dm644 zsh.comp "$pkgdir"/usr/share/zsh/site-functions/_glab
	install -Dm644 fish.comp "$pkgdir"/usr/share/fish/completions/glab.fish
}
sha512sums="
1948e9c330c31240fcfa5fdcae597b4ae11b1df2d3d5d85a095913988a8f5483107202ce66a474c081cc4b8a44cc5b317dc1f65f75f6b0c3e11308e2bb2b91b5  glab-1.22.0.tar.gz
"
